<script setup lang="ts">
import { fetchGeneralDataAPI } from './apis/fetchGeneralData'
import { useGeneralDataStore } from './store/generalData'
import { fetchDomainAPI } from '@/apis/fetchDomain'

const generalDataStore = useGeneralDataStore()

onLaunch(async () => {
  const res = await fetchDomainAPI()
  if ((res.data as any).code === 1)
    uni.setStorageSync('domain', (res.data as any).data)
  else
    uni.showToast({ title: (res.data as any).msg, icon: 'none' })

  const generalDataRes = await fetchGeneralDataAPI()

  if (generalDataRes.data?.code === 1)
    generalDataStore.setGeneralData(generalDataRes.data.data)
  else
    uni.showToast({ title: generalDataRes.data?.msg, icon: 'none' })
})
</script>

<style>
view, input {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

button {
  margin: 0;
  padding: 0;
}

button::after {
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.skeleton {
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, .5) 50%,
    rgba(255, 255, 255, 0) 80%
  ) #D9D9D9;
  background-size: 200% 100%;
  background-position-x: 180%;
  animation: 1s loading ease-in-out infinite;
}

@keyframes loading {
  to {
    background-position-x: -20%;
  }
}
</style>
